// 待办列表
var thingsGridColumns = [{
    id: 'lcCode',
    title: '流程编码',
    type: 'string',
    width: 280,
    columnClass: 'text-center',
},{
        id: 'title',
        title: '流程步骤',
        width: 250,
        type: 'string',
        columnClass: 'text-center',
    },
    {
        id: 'sqNr',
        title: '流程名称',
        type: 'string',
        columnClass: 'text-left',
    },
    
    {
        id: 'lcInitiatorName',
        title: '发起人',
        type: 'string',
        width: 75,
        columnClass: 'text-center',
    },
    {
        id: 'createTime',
        title: '提交时间',
        type: 'date',
        width: 150,
        format: 'yyyy-MM-dd',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var date = new Date(record.createTime);
            var content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd hh:mm");
            return content;
        }
    },
    {
        id: 'operation',
        title: '操作',
        width: 60,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '';
            content += '<button class="btn btn-xs btn-primary" onclick="toInititor(\'' + record.id + '\');"' + '><i class="icon-eye-open"></i>  查看</button>';
            return content;
        }
    }
];

function myInitiatorGrid(CertusFormAjax, $routeParams, $scope, CertusJsonAjax, $http) {
    var dataInit = CertusJsonAjax.dataInit("queryMyInitiatorGrid", null, thingsGridColumns, 'thingsDataGirdInititor', 'thingsGridToolBarContainerInitiator');

    $("#dateTimeSearch1").datetimepicker({
        format: 'YYYY-MM-DD',
        locale: moment.locale('zh-cn')
    }).on('dp.change', function (e) {
        var result = new moment(e.date).format('YYYY-MM-DD');
        if (result && !angular.isUndefined(result)) {
            $scope.search.time = result;
            $scope.$apply();
        }
    });
    $scope.search = {};

    $scope.clearSearch = function(){
        $scope.search = {};
        $("#dateTimeSearch1").val("");
    }
    //watch 函数
    $scope.$watch("search",function(newValue,oldValue,c){

        dataInit.parameters = $scope.search;
        dataInit.refresh(true);
    },true)
}

// 待办类型跳转
function toInititor(scheduleId) {
    window.location.href = "#/routered/" + scheduleId;
}